<template>
  <div class="container">
    <textarea 
      v-model="inputContent" 
      placeholder="请输入需要转换的文字"
      class="input-area"
      rows="5"
    ></textarea>

    <button 
      class="convert-btn"
      @click="startChange"
    >
      转换为语音
    </button>
  </div>
</template>

<script setup lang="ts">
import { ref } from "vue";
import tts from '../synth';

const inputContent = ref('');

const startChange = () => {
  if (inputContent.value.trim()) {
    tts.speek(inputContent.value);
  }
};
</script>

<style scoped>
.container {
  max-width: 600px;
  margin: 2rem auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.input-area {
  width: 100%;
  padding: 1rem;
  border: 2px solid #42b883;
  border-radius: 8px;
  font-size: 1rem;
  resize: vertical;
  min-height: 120px;
  transition: border-color 0.3s ease;
}

.input-area:focus {
  outline: none;
  border-color: #2c7a5b;
  box-shadow: 0 0 0 3px rgba(66, 184, 131, 0.2);
}

.convert-btn {
  align-self: flex-end;
  padding: 0.8rem 1.5rem;
  background-color: #42b883;
  width: 100%;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  transition: 
    background-color 0.3s ease,
    transform 0.2s ease;
}

.convert-btn:hover {
  background-color: #2c7a5b;
  transform: translateY(-1px);
}

.convert-btn:active {
  transform: translateY(0);
}

.convert-btn:disabled {
  background-color: #cccccc;
  cursor: not-allowed;
}
</style>